package com.such.kit.database.bean;

import java.util.HashMap;
import java.util.Map;
import com.such.kit.database.dialect.TypeFactory;
import com.such.kit.database.support.DDLBean;
import com.such.kit.validate.ValidateCommons;

/**
 * @作者 SUCH
 * @日期 2017-9-12 下午1:50:55
 * @描述 DDL Schema 对象
 */
public class DDLSchema extends DDLBean<DatabaseSchema> {

	private static final long serialVersionUID = -6162898548202595358L;

	private String schema;

	public DDLSchema() {
		
	}

	public DDLSchema(DatabaseSchema schema) {
		converter(schema);
	}

	public String getSchema() {
		return this.schema;
	}

	public void setSchema(String schema) {
		this.schema = schema;
	}

	public void converter(DatabaseSchema schema) {
		if (ValidateCommons.isNotEmpty(schema)) {
			setSchema(schema.getSchema());
		}
	}

	public Map<String, String> buildRendererParams(Map<String, String> resourceKeyMapping, Map<String, String> ddlTemplateMapping, Map<String, String> params, TypeFactory type) {
		Map<String, String> schemaParams = new HashMap<String, String>();
		if (ValidateCommons.isNotEmpty(params)) {
			schemaParams.putAll(params);
		}
		putString("schema", this.schema, schemaParams, resourceKeyMapping, ddlTemplateMapping);
		return schemaParams;
	}

}
